%Deze m-file plot alle gevraagde figuren:


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% Plotten kosten per jaar per sector in functie van de
%%%%%%%%%%%%% belastingsbus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sectoren_namen;
plot_matrix_kosten=zeros(aantal_belastingsbussen,aantal_sectoren);
namen_sectoren = transpose(sectoren);
labels_sectoren = transpose(sectoren2);
for i=1:1:aantal_belastingsbussen
    close all;
    nummerbelastingsbus = int2str(belastingsbussen(i));
    test_string = strcat('problemen_bus_',nummerbelastingsbus);    
    if 1==exist(test_string)
    naam_kosten_matrix = eval('test_string');
    [r,k]=size(eval(naam_kosten_matrix));
    for j=1:1:aantal_sectoren
    temp=0;
        for x=1:1:r
            toppie = eval(naam_kosten_matrix);
            temp = temp + toppie(x,7+j);
        end
        plot_matrix_kosten(i,j) = temp;
    end
    end
end
for i=1:1:aantal_belastingsbussen
    close all;
    nummerbelastingsbus = int2str(belastingsbussen(i));
    titel = strcat({'Kosten PQ belastingsbus nummer '},nummerbelastingsbus);
    naam_ylabel = strcat('Kosten [euro/jaar]');
    scrsz = get(0,'ScreenSize');
    q=figure('Position',[1 scrsz(4) scrsz(3)/1 scrsz(4)/1.2])
    whitebg('white');
    kleur = [1 0.7 0.9];
    bar(plot_matrix_kosten(i,1:aantal_sectoren));
    colormap([ 0.33 0.33 0.7]) 
    shading faceted
    grid on;
    axis([0 aantal_sectoren+1 0 1.02*max(plot_matrix_kosten(i,1:aantal_sectoren))]);
    set(gca,'XTick',[1:aantal_sectoren]);
    set(gca,'XTickLabels',labels_sectoren);
    xticklabel_rotate([],50,labels_sectoren);
    ylabel(naam_ylabel);
    title(titel);
    naam_pdf=strcat('kost_PQ_bus_',nummerbelastingsbus);%,'.pdf');
    orient landscape;
    print(q,'-dpdf',naam_pdf);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% Plotten kosten per jaar per sector in functie van de
%%%%%%%%%%%%% belastingsbus, genormaliseerd naar het vermogen op de bus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

plot_matrix_kosten_norm=zeros(aantal_belastingsbussen,aantal_sectoren);
namen_sectoren = transpose(sectoren);whitebg([0 1 0]);
for i=1:1:aantal_belastingsbussen
    close all;
    nummerbelastingsbus = int2str(belastingsbussen(i));
    test_string = strcat('problemen_bus_',nummerbelastingsbus);
    if 1==exist(test_string)
    naam_kosten_matrix = eval('test_string');
    [r,k]=size(eval(naam_kosten_matrix));
    for j=1:1:aantal_sectoren
    temp=0;
        for x=1:1:r
            toppie = eval(naam_kosten_matrix);
            temp = temp + (toppie(x,7+j)/vermogen(i));
        end
        plot_matrix_kosten_norm(i,j) = temp;
    end
    end
end
for i=1:1:aantal_belastingsbussen
    close all;
    nummerbelastingsbus = int2str(belastingsbussen(i));
    titel = strcat({'Kosten PQ belastingsbus nummer '}, nummerbelastingsbus ,{', genormaliseerd naar vermogen'});
    naam_ylabel = strcat('Kosten [euro/(jaar.kW)]');
    scrsz = get(0,'ScreenSize');
    q=figure('Position',[1 scrsz(4) scrsz(3)/1 scrsz(4)/1.2]);
    colormap([ 0.9 0.2 0.2]) 
    whitebg('white');
    bar(plot_matrix_kosten_norm(i,1:aantal_sectoren));
    grid on;
    axis([0 aantal_sectoren+1 0 1.02*max(plot_matrix_kosten_norm(i,1:aantal_sectoren))]);
    set(gca,'XTick',[1:aantal_sectoren]);
    set(gca,'XTickLabels',labels_sectoren);
    xticklabel_rotate([],50,labels_sectoren);
    ylabel(naam_ylabel);
    title(titel);
    naam_pdf=strcat('kost_PQ_bus_',nummerbelastingsbus,'_genormaliseerd_naar_vermogen.pdf');
    orient landscape;
    print(q,'-dpdf',naam_pdf);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% Plotten kosten mitigatiemiddelen per jaar per sector 
%%%%%%%%%%%%% in functie van de belastingsbus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

plot_matrix_mitigatiemiddelen = zeros(aantal_belastingsbussen,aantal_sectoren);
namen_sectoren = transpose(sectoren);
for i=1:1:aantal_sectoren
    naamsector = namen_sectoren(i,:);
    test_string = strcat('kosten_sector_',naamsector);
    test_string=char(test_string);
    if 1==exist(test_string);
        naam_kosten_matrix = eval('test_string');
        for j=1:1:aantal_belastingsbussen
            nummer_bus = belastingsbussen(j)
            tini=eval(naam_kosten_matrix);
            plot_matrix_mitigatiemiddelen(j,i)=tini(j,3);
        end
    end
end
for i=1:1:aantal_belastingsbussen
    close all;
    nummerbelastingsbus = int2str(belastingsbussen(i));
    titel = strcat({'Kosten mitigatiemiddelen belastingsbus nummer '},nummerbelastingsbus);
    naam_ylabel = strcat('Kosten [euro/jaar]');
    scrsz = get(0,'ScreenSize');
    q=figure('Position',[1 scrsz(4) scrsz(3)/1 scrsz(4)/1.2]);
    colormap([ 0.2 0.87 0.2]) 
    whitebg('white');
    bar(plot_matrix_mitigatiemiddelen(i,1:aantal_sectoren));
    grid on;
    axis([0 aantal_sectoren+1 0 1.02*max(plot_matrix_mitigatiemiddelen(i,1:aantal_sectoren))]);
    set(gca,'XTick',[1:aantal_sectoren]);
    set(gca,'XTickLabels',labels_sectoren);
    xticklabel_rotate([],50,labels_sectoren);
    ylabel(naam_ylabel);
    title(titel);
    naam_pdf=strcat('kost_mitigatiemiddelen_bus_',nummerbelastingsbus,'.pdf');
    orient landscape;
    print(q,'-dpdf',naam_pdf);
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% Plotten kosten mitigatiemiddelen per jaar per sector 
%%%%%%%%%%%%% in functie van de belastingsbus, genormaliseerd naar vermogen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

plot_matrix_mitigatiemiddelen_norm = zeros(aantal_belastingsbussen,aantal_sectoren);
namen_sectoren = transpose(sectoren);
for i=1:1:aantal_sectoren
    naamsector = namen_sectoren(i,:);
    test_string = strcat('kosten_sector_',naamsector);
    test_string=char(test_string);
    if 1==exist(test_string);
        naam_kosten_matrix = eval('test_string');
        for j=1:1:aantal_belastingsbussen
            nummer_bus = belastingsbussen(j)
            tini=eval(naam_kosten_matrix);
            plot_matrix_mitigatiemiddelen_norm(j,i)=(tini(j,3)/vermogen(j));
        end
    end
end
for i=1:1:aantal_belastingsbussen
    close all;
    nummerbelastingsbus = int2str(belastingsbussen(i));
    titel = strcat({'Kosten mitigatiemiddelen belastingsbus nummer '},nummerbelastingsbus, {', genormaliseerd naar vermogen'});
    naam_ylabel = strcat('Kosten [euro/jaar.kW]');
    scrsz = get(0,'ScreenSize');
    q=figure('Position',[1 scrsz(4) scrsz(3)/1 scrsz(4)/1.2]);
    bar(plot_matrix_mitigatiemiddelen_norm(i,1:aantal_sectoren));
    colormap([ 1 0.9 0.1]) 
    whitebg('white');
    grid on;
    axis([0 aantal_sectoren+1 0 1.02*max(plot_matrix_mitigatiemiddelen_norm(i,1:aantal_sectoren))]);
    set(gca,'XTick',[1:aantal_sectoren]);
    set(gca,'XTickLabels',labels_sectoren);
    xticklabel_rotate([],50,labels_sectoren);
    ylabel(naam_ylabel);
    title(titel);
    naam_pdf=strcat('kost_mitigatiemiddelen_norm_bus_',nummerbelastingsbus,'.pdf');
    orient landscape;
    print(q,'-dpdf',naam_pdf);
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% Plotten kosten mitigatiemiddelen per jaar per sector 
%%%%%%%%%%%%% in functie van de belastingsbus en de PQ-kosten per jaar ifv
%%%%%%%%%%%%% de belastingsbus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


for i=1:1:aantal_belastingsbussen
    close all;
    nummerbelastingsbus = int2str(belastingsbussen(i));
    titel = strcat({'Kosten mitigatiemiddelen en PQ-problemen op belastingsbus nummer '},nummerbelastingsbus);
    naam_ylabel = strcat('Kosten [euro/jaar]');
    scrsz = get(0,'ScreenSize');
    q=figure('Position',[1 scrsz(4) scrsz(3)/1 scrsz(4)/1.2]);
    colormap summer % Change the color scheme
    whitebg('white');
    toplot=vertcat(plot_matrix_mitigatiemiddelen(i,1:aantal_sectoren),plot_matrix_kosten(i,1:aantal_sectoren));%aanmaken van een matrix met daarin als rijen de twee te plotten variabelen, de kolommen komen overeen met de sectoren
    bar(transpose(toplot),'grouped');
    legend('Kosten Mitigatiemiddelen','Kosten PQ-problemen')
    grid on;
    set(gca,'XTick',[1:aantal_sectoren]);
    set(gca,'XTickLabels',labels_sectoren);
    xticklabel_rotate([],50,labels_sectoren);
    ylabel(naam_ylabel);
    title(titel);
    naam_pdf=strcat('kost_mitigatiemiddelenen_en_PQ_bus_',nummerbelastingsbus,'.pdf');
    orient landscape;
    print(q,'-dpdf',naam_pdf);
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% Plotten kosten mitigatiemiddelen per jaar per sector 
%%%%%%%%%%%%% in functie van de belastingsbus en de PQ-kosten per jaar ifv
%%%%%%%%%%%%% de belastingsbus, beiden genormaliseerd naar vermogen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


for i=1:1:aantal_belastingsbussen
    close all;
    nummerbelastingsbus = int2str(belastingsbussen(i));
    titel = strcat({'Kosten mitigatiemiddelen en PQ-problemen op belastingsbus nummer '},nummerbelastingsbus,{', beiden genormaliseerd naar vermogen'});
    naam_ylabel = strcat('Kosten [euro/(jaar.kW)]');
    scrsz = get(0,'ScreenSize');
    q=figure('Position',[1 scrsz(4) scrsz(3)/1 scrsz(4)/1.2]);
    colormap summer % Change the color scheme
    whitebg('white');
    toplot=vertcat(plot_matrix_mitigatiemiddelen_norm(i,1:aantal_sectoren),plot_matrix_kosten_norm(i,1:aantal_sectoren));%aanmaken van een matrix met daarin als rijen de twee te plotten variabelen, de kolommen komen overeen met de sectoren
    bar(transpose(toplot),'grouped');
    legend('Genormaliseerde kosten mitigatiemiddelen','Genormaliseerde kosten PQ-problemen')
    grid on;
    set(gca,'XTick',[1:aantal_sectoren]);
    set(gca,'XTickLabels',labels_sectoren);
    xticklabel_rotate([],50,labels_sectoren);
    ylabel(naam_ylabel);
    title(titel);
    naam_pdf=strcat('kost_mitigatiemiddelen_en_PQ_bus_',nummerbelastingsbus,'_beiden_genormaliseerd.pdf');
    orient landscape;
    print(q,'-dpdf',naam_pdf);
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% Plotten kosten mitigatiemiddelen per jaar per sector 
%%%%%%%%%%%%% in functie van de belastingsbus en de PQ-kosten per jaar ifv
%%%%%%%%%%%%% de belastingsbus in 3D
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% for i=1:1:aantal_belastingsbussen
%     close all;
%     nummerbelastingsbus = int2str(belastingsbussen(i));
%     titel = strcat({'Kosten mitigatiemiddelen en PQ-problemen op belastingsbus nummer '},nummerbelastingsbus);
%     naam_zlabel = strcat('Kosten [euro/jaar]');
%     scrsz = get(0,'ScreenSize');
%     q=figure('Position',[1 scrsz(4) scrsz(3)/1 scrsz(4)/1.2]);
%     colormap summer % Change the color scheme
%     whitebg('white');
%     toplot=vertcat(plot_matrix_mitigatiemiddelen(i,1:aantal_sectoren),plot_matrix_kosten(i,1:aantal_sectoren));%aanmaken van een matrix met daarin als rijen de twee te plotten variabelen, de kolommen komen overeen met de sectoren
%     bar3(transpose(toplot),'grouped');
%     legend('Kosten Mitigatiemiddelen','Kosten PQ-problemen')
%     grid on;
%     set(gca,'YTick',[1:aantal_sectoren]);
%     set(gca,'YTickLabels',labels_sectoren);
%     %xticklabel_rotate([],50,labels_sectoren);
%     zlabel(naam_zlabel);
%     title(titel);
%     naam_pdf=strcat('kost_mitigatiemiddelenen_en_PQ_bus_',nummerbelastingsbus,'_3D.pdf');
%     orient landscape;
%     print(q,'-dpdf',naam_pdf);
% end
